Skip to content

Conversation

rpkilby
Copy link
Contributor

@rpkilby rpkilby commented Jan 15, 2020

This fixes #7100 which was caused by related changes in #7086. Model serializers will now correctly use serializer field names that map to the field sources in unique_together. If there are multiple fields that use the same source (seems unlikely but doesn't hurt to check?), then an error is raised instead. Note that the error is raised somewhat late during validation, but that's when the validators are generated. We could create/cache them on __init__ (maybe cache fields and validators?), but that seems like a separate discussion.

Updates ModelSerializer to check for serializer fields that map to the
model field sources in the unique_together lists.
@tarzzz
Copy link

tarzzz commented Feb 28, 2020

Bump on this. I am affected as well.

When can we expect this to be merged and available in a release?

@carltongibson carltongibson added this to the 3.12 Release milestone Mar 3, 2020
@rpkilby
Copy link
Contributor Author

rpkilby commented Mar 3, 2020

@carltongibson are we planning another 3.11.x release, or straight to 3.12?

@carltongibson
Copy link
Collaborator

I'm mentally lining up a 3.12, but we can call it 3.11.1 if you like. 😀

(There's quite a few schema changes that merit an announcement post I'd say so...)

@auvipy
Copy link
Collaborator

auvipy commented Mar 4, 2020

3.12 in this month would be really great :)

@lovelydinosaur
Copy link
Contributor

@carltongibson Seems sensible yup - I'd happily carve out some of my working time for that.

@auvipy
Copy link
Collaborator

auvipy commented May 12, 2020

@lovelydinosaur lovelydinosaur merged commit 089162e into encode:master May 13, 2020
@lovelydinosaur
Copy link
Contributor

Fantastic stuff, @rpkilby!

@rpkilby rpkilby deleted the uniquetogether-field-source branch May 13, 2020 17:31
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
…e#7143)

* Fix ModelSerializer unique_together field sources

Updates ModelSerializer to check for serializer fields that map to the
model field sources in the unique_together lists.

* Ensure field name ordering consistency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ModelSerializer UniqueTogetherValidator is incompatible with field source
5 participants